#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

void print(int arr[], int sz)
{
	for (int i = 0; i < sz; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");
}

void merge(int arr1[], int arr2[], int m, int n)
{
	int end1 = m - 1;
	int end2 = n - 1;
	int dst = m + n - 1;

	while (end1 >= 0 && end2 >= 0)
	{
		if (arr1[end1] > arr2[end2])
		{
			arr1[dst--] = arr1[end1--];
		}
		else
		{
			arr1[dst--] = arr2[end2--];
		}
	}

	while (end2 >= 0)
	{
		arr1[dst--] = arr2[end2--];
	}
}

int main()
{
	int arr1[] = { 1,2,3,0,0,0 };
	int arr2[] = { 2,5,6 };
	int m = 3, n = 3;
	print(arr1, m + n);
	print(arr2, n);

	merge(arr1,arr2,3,3);
	print(arr1, m + n);
	return 0;
}